/* 
 * File:   V4LCapture.hpp
 * Author: gustavo
 *
 * Created on August 29, 2012, 11:08 AM
 */

#ifndef V4LCAPTURE_HPP
#define	V4LCAPTURE_HPP


#include "impl/v4l.h"

namespace imp {
	namespace capture {

		class V4LCapture {
			/////
		private:
			struct v4l_driver v4l_drv;


		public: /* Constructors */
			V4LCapture();
			virtual ~V4LCapture();

		public: /* Methods */
			bool open(const char * device);
			bool is_opened();
			bool close();
			bool start();
			bool stop();

			void get_image_size(int * width, int * height);

			void * grab_raw();
			void grab_and_fill_gray(char * gray);
			void grab_and_fill_rgb(char * rgb);

			static std::list<char *> * get_device_list();

			const char * get_device_name();
			const char * get_device_card();
			const char * get_device_driver();
			const char * get_device_bus();

			bool enum_input(struct v4l2_input * input, int init = 0);
			bool enum_standard(struct v4l2_standard * standard, int init = 0);
			bool enum_format_desc(struct v4l2_fmtdesc * fmtdesc, int init = 0);
			bool enum_frame_size(struct v4l2_frmsizeenum * frmsize, int init = 0);
			bool enum_control_default(struct v4l2_queryctrl * qctrl, int init = 0);
			bool enum_control_user(struct v4l2_queryctrl * qctrl, int init = 0);
			bool enum_control_private(struct v4l2_queryctrl * qctrl, int init = 0);

			bool get_control(struct v4l2_control * ctrl, int ctrl_id);
			bool get_control_menu(struct v4l2_querymenu * qmenu, int ctrl_id, int index);

			bool get_input(struct v4l2_input * input);
			bool get_standard(struct v4l2_standard * standard);
			bool get_format(struct v4l2_format * format);
			bool get_format_desc(struct v4l2_fmtdesc * fmtdesc);



			bool set_input(int index);
			bool set_standard(int id);
			bool set_pixel_format(int pixel_format);
			bool set_frame_size(int width, int height);
			bool set_control(int ctrl_id, int value);


		private:

		};
	}
}
#endif	/* V4LCAPTURE_HPP */

